import Vue from 'vue'
export default {
	save (res) {
		return new Promise(resolve => {
			const { resultCode, msg } = res
			if (!resultCode) {
				Vue.prototype.$fxMessage.warning(msg).then(() => {
					resolve(res)
				})
			}
			if (resultCode) {
				Vue.prototype.$fxMessage.success(msg).then(() => {
					resolve(res)
				})
			}
		})
	},
	deleteMulity (res) {
		return new Promise(resolve => {
			const { resultCode, msg, batchFailFlag } = res
			if (!resultCode) {
				Vue.prototype.$fxMessage.warning(msg).then(() => {
					resolve(res)
				})
			}
			if (resultCode && !batchFailFlag) {
				Vue.prototype.$fxMessage.success(msg).then(() => {
					resolve(res)
				})
			}
			if (resultCode && batchFailFlag) {
				Vue.prototype.$fxMessage.error(msg).then(() => {
					resolve(res)
				})
			}
		})
	},
	enableMulity (res) {
		return new Promise(resolve => {
			const { resultCode, msg, batchFailFlag } = res
			if (!resultCode) {
				Vue.prototype.$fxMessage.warning(msg).then(() => {
					resolve(res)
				})
			}
			if (resultCode && !batchFailFlag) {
				Vue.prototype.$fxMessage.success(msg).then(() => {
					resolve(res)
				})
			}
			if (resultCode && batchFailFlag) {
				Vue.prototype.$fxMessage.error(msg).then(() => {
					resolve(res)
				})
			}
		})
	},
	disableMulity (res) {
		return new Promise(resolve => {
			const { resultCode, msg, batchFailFlag } = res
			if (!resultCode) {
				Vue.prototype.$fxMessage.warning(msg).then(() => {
					resolve(res)
				})
			}
			if (resultCode && !batchFailFlag) {
				Vue.prototype.$fxMessage.success(msg).then(() => {
					resolve(res)
				})
			}
			if (resultCode && batchFailFlag) {
				Vue.prototype.$fxMessage.error(msg).then(() => {
					resolve(res)
				})
			}
		})
	},
	copyMulity (res) {
		return new Promise(resolve => {
			const { resultCode, msg, batchFailFlag } = res
			if (!resultCode) {
				Vue.prototype.$fxMessage.warning(msg).then(() => {
					resolve(res)
				})
			}
			if (resultCode && !batchFailFlag) {
				Vue.prototype.$fxMessage.success(msg).then(() => {
					resolve(res)
				})
			}
			if (resultCode && batchFailFlag) {
				Vue.prototype.$fxMessage.error(msg).then(() => {
					resolve(res)
				})
			}
		})
	}
}
